﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using EvaluacionExalmarOledbHelper;
using EvaluacionExalmarEntidades;
using EvaluacionExalmarInterfaces;
using System.Configuration;
using System.Text;

namespace EvaluacionExalmarAccesoDatos
{
    public class Competencia : ICompetencia
    {
        #region ICompetencia Members

        private readonly String _sCadenaConexion =
ConfigurationManager.ConnectionStrings["con"].ConnectionString;

        public CompetenciaInfo Consultar(CompetenciaInfo oCompetencia)
        {
            throw new NotImplementedException();
        }

        public IList<CompetenciaInfo> Listar(CompetenciaInfo oCompetencia)
        {
            const string query = "Select Id_Competencia, Descripcion, Detalle from Competencia order by Id_Competencia";
            var oListaCompetencias = new List<CompetenciaInfo>();

            using (var drd = OleDbHelper.ExecuteReader(_sCadenaConexion, CommandType.Text, query))
            {
                if (drd != null)
                {
                    if (drd.HasRows)
                    {
                        while (drd.Read())
                        {
                            oListaCompetencias.Add(new CompetenciaInfo(drd.GetInt32(0), drd.GetString(1).Trim(), drd.GetString(2).Trim()));
                        }
                    }
                }
            }

            return oListaCompetencias;
        }

        #endregion
    }
}
